﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
//using System.Web.Caching;
using System.Web;
namespace DAO
{
  public abstract  class IData
    {
  //    private Cache _cache = HttpContext.Current.Cache;
      protected SQLData connec = null;
      protected String strAsc = " order by orderId desc ";
      protected String strSelect = "select * from ";

      public IData() { 

      }
      public IData(String m_connec) {
          connec = new SQLData(m_connec);
      }

      public virtual IDataReader getReader(String sp_proc, String sparam, Object id)
      {
          SqlConnection connection = connec.Connection;
          SqlCommand command = new SqlCommand();
          SqlParameter p = new SqlParameter();
          p.Direction = ParameterDirection.Output;
          command.CommandType = CommandType.StoredProcedure;
          command.CommandText = sp_proc;
          command.Connection = connection;
          command.Parameters.Add("@" + sparam,SqlDbType.BigInt).Value = id;
          connection.Open();
          SqlDataReader reader;
          //IDataReader ireader = null;
          using (reader = command.ExecuteReader(CommandBehavior.CloseConnection))
          {
              while (reader.Read())
              {
                  //ireader = reader;                  
                  return reader;
              }
             // reader.Close();
          }
          connection.Close();
          return null;
      } 
    }
}
